package com.sojpt.util;


import lombok.Data;

@Data
public class ResultUtil {

    private String success="true"; //判断系统是否出错做出相应的true或者false的返回，与业务无关，出现的各种异常

    private String errorCode="0";//该错误码为自定义，一般0表示无错

    private String msg;//对应的提示信息

    private Object data;//具体返回数据内容(pojo、自定义VO、其他)

    public static ResultUtil success(){
        ResultUtil resultUtil = new ResultUtil();
        return  resultUtil;
    }

    public static ResultUtil success(String message,Object data){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setMsg(message);
        resultUtil.setData(data);
        return  resultUtil;
    }
    public static ResultUtil success(String message){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setMsg(message);
        return  resultUtil;
    }


    public static ResultUtil success(Object data){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setData(data);
        return  resultUtil;
    }

    public static ResultUtil failed(String message,String errorCode){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setSuccess("false");
        resultUtil.setMsg(message);
        resultUtil.setErrorCode(errorCode);
        return  resultUtil;
    }

}
